﻿@model TWCRM.Models.Home.ChangePasswordModel
@{
    Layout = "/Views/Shared/_SubLayout.cshtml";
    ViewBag.Title = "修改密碼";
}
<script>
    $(document).ready(function () {
        $.fn.keyBinding($('.metro_input_btn'));

        $.fn.metro.onPrevClick = function () {
            window.history.go(-1);
        };

        var maxCaptionWidth = $.fn.calcMaxWidth($('.metro_input_caption'));
        $('.metro_input_caption').each(function () {
            $(this).width(maxCaptionWidth);
        });
    });

    function confirm() {
        if (!valEmpty($("#OldPassword"))) {
            showError("目前密碼是必要欄位不可留白");
            return;
        }
        if (!valEmpty($("#Password"))) {
            showError("新密碼是必要欄位不可留白");
            return;
        }
        if (!valEmpty($("#ConfirmPassword"))) {
            showError("確認新密碼是必要欄位不可留白");
            return;
        }

        showLoading();
        $('form').submit();
    };
</script>
<div id="ChangePassword">
    @using (Html.BeginForm())
    {
        <div class="metro_input_contain">
            <label for="OldPassword" class="metro_input_caption">
                目前密碼
            </label>
            @Html.PasswordFor(m => m.OldPassword, new { @class = "metro_input_passinput"})
            @Html.ValidationMessageFor(m => m.OldPassword, new { @class = "metro_validate" })
        </div>
        <div class="metro_input_contain">
            <label for="Password" class="metro_input_caption">
                新密碼
            </label>
            @Html.PasswordFor(m => m.Password, new { @class = "metro_input_passinput" })
            @Html.ValidationMessageFor(m => m.Password, new { @class = "metro_validate" })
        </div>
        <div class="metro_input_contain">
            <label for="ConfirmPassword" class="metro_input_caption">
                確認新密碼
            </label>
            @Html.PasswordFor(m => m.ConfirmPassword, new { @class = "metro_input_passinput" })
            @Html.ValidationMessageFor(m => m.ConfirmPassword, new { @class = "metro_validate" })
        </div>
        <div class="metro_input_contain">
            @Html.ValidationMessage("", new { @class = "metro_validate" })
        </div>
        <div class="metro_input_contain">
            <a class="metro_input_btn" onclick="confirm()">儲存</a>
        </div>
    }
</div>
